export default defineEventHandler(async (event) => {
  const query = getQuery(event);
  const { location, keywords, radius = 3000, types } = query;
  
  // 模拟延迟
  await new Promise(resolve => setTimeout(resolve, 400));
  
  try {
    if (!location) {
      throw createError({
        statusCode: 400,
        statusMessage: '缺少必要参数：location'
      });
    }
    
    // 模拟POI数据
    const mockPoiData = {
      success: true,
      data: [
        {
          id: 'B0FFJQ1QJN',
          name: '广州塔',
          type: '风景名胜',
          typecode: '110000',
          address: '广东省广州市海珠区阅江西路222号',
          location: '113.289405,23.013125',
          distance: '500',
          tel: '020-89338222',
          website: 'www.cantontower.com',
          email: 'info@cantontower.com',
          pcode: '440000',
          citycode: '020',
          adcode: '440105',
          cityname: '广州市',
          adname: '海珠区',
          importance: '1',
          shopinfo: '0',
          poiweight: '1',
          gridcode: '440105001001',
          navi_poiid: 'B0FFJQ1QJN',
          entrances: [
            {
              location: '113.289405,23.013125',
              name: '正门'
            }
          ],
          exits: [
            {
              location: '113.289405,23.013125',
              name: '正门'
            }
          ]
        },
        {
          id: 'B0FFJQ1QJO',
          name: '珠江新城地铁站',
          type: '交通设施',
          typecode: '150000',
          address: '广东省广州市天河区珠江新城',
          location: '113.287405,23.011125',
          distance: '800',
          tel: '020-96900',
          pcode: '440000',
          citycode: '020',
          adcode: '440106',
          cityname: '广州市',
          adname: '天河区',
          importance: '1',
          shopinfo: '0',
          poiweight: '1',
          gridcode: '440106001001',
          navi_poiid: 'B0FFJQ1QJO'
        },
        {
          id: 'B0FFJQ1QJP',
          name: '广州图书馆',
          type: '科教文化',
          typecode: '140000',
          address: '广东省广州市天河区珠江新城花城大道',
          location: '113.286405,23.012125',
          distance: '1200',
          tel: '020-83836666',
          website: 'www.gzlib.gov.cn',
          pcode: '440000',
          citycode: '020',
          adcode: '440106',
          cityname: '广州市',
          adname: '天河区',
          importance: '1',
          shopinfo: '0',
          poiweight: '1',
          gridcode: '440106001002',
          navi_poiid: 'B0FFJQ1QJP'
        },
        {
          id: 'B0FFJQ1QJQ',
          name: '星巴克咖啡(珠江新城店)',
          type: '餐饮服务',
          typecode: '050000',
          address: '广东省广州市天河区珠江新城花城大道85号',
          location: '113.285405,23.013125',
          distance: '1500',
          tel: '020-12345678',
          pcode: '440000',
          citycode: '020',
          adcode: '440106',
          cityname: '广州市',
          adname: '天河区',
          importance: '1',
          shopinfo: '1',
          poiweight: '1',
          gridcode: '440106001003',
          navi_poiid: 'B0FFJQ1QJQ'
        },
        {
          id: 'B0FFJQ1QJR',
          name: '广州银行(珠江新城支行)',
          type: '金融保险',
          typecode: '160000',
          address: '广东省广州市天河区珠江新城花城大道100号',
          location: '113.284405,23.014125',
          distance: '1800',
          tel: '020-87654321',
          pcode: '440000',
          citycode: '020',
          adcode: '440106',
          cityname: '广州市',
          adname: '天河区',
          importance: '1',
          shopinfo: '0',
          poiweight: '1',
          gridcode: '440106001004',
          navi_poiid: 'B0FFJQ1QJR'
        }
      ],
      count: 5,
      message: 'POI搜索成功'
    };
    
    // 根据关键词过滤
    if (keywords) {
      const keyword = keywords.toString().toLowerCase();
      mockPoiData.data = mockPoiData.data.filter(poi => 
        poi.name.toLowerCase().includes(keyword) || 
        poi.type.toLowerCase().includes(keyword)
      );
      mockPoiData.count = mockPoiData.data.length;
    }
    
    // 根据类型过滤
    if (types) {
      const type = types.toString().toLowerCase();
      mockPoiData.data = mockPoiData.data.filter(poi => 
        poi.type.toLowerCase().includes(type)
      );
      mockPoiData.count = mockPoiData.data.length;
    }
    
    return mockPoiData;
  } catch (error) {
    console.error('POI搜索API模拟数据生成失败:', error);
    throw createError({
      statusCode: 500,
      statusMessage: 'POI搜索失败'
    });
  }
}); 